package model

import (
	"fmt"
	"log"
	"time"
)

type monitor struct {
	startTme int64
	endTme   int64
}

func NewMonitor() *monitor {
	return &monitor{}
}

func (m *monitor) Start() *monitor {
	m.startTme = time.Now().UnixMilli()
	return m
}

func (m *monitor) End() *monitor {
	m.endTme = time.Now().UnixMilli()
	return m
}

func (m *monitor) Cost() int64 {
	return m.endTme - m.startTme
}
func (m *monitor) Println(logger *log.Logger, pattern string, a ...any) {
	logger.Printf(pattern+" | "+fmt.Sprintf("cost [%d] ms. \n", m.End().Cost()), a...)
}
